import os
import sys

# 请在此输入您的代码

n, d = map(int, input().split())

a = list(map(int, input().split()))

left = 0
right = left + d -1
# cnt_set = set(a[left, right +1])
# cnt = len(set(a[left, right + 1]))
cnt = 1e8
while right < n:
  cnt = min(cnt, len(set(a[left:right + 1])))
  left += 1
  right += 1

print(cnt)